#!/bin/bash
# backup.sh
# Written by James Kelly <kellyjh@dcs.gla.ac.uk>
# Used with permission.
# This program recursively backs up files.
# Create tar from the current date


XPECTED_ARGS=1
E_BADARGS=65
check_args_num(){
if [ $1 -gt $EXPECTED_ARGS ]
then
  echo usage: $0 one or more directories
  exit 0
fi
}

if [ -z "$1" ]; then 
      echo usage: $0 directory
      exit
fi
}


search_recursively () {
# Gives each individual file a sha1sum
for file in `ls $1`;  do

if [ -d $1/$file ];  then # If file is a directory
		echo "Directory: ";
		add_directory $1/$file 
	else   
	 	# Change to a Temp file
		sha1sum $1/$file >> ~/$BACKUPFILE-SHA1SUMS.log  
		echo $1/$file
fi
done
}

# main
check_args_num
search_recursively
exit 1

